<?php
echo $this->Html->css('form');
echo $this->Html->script('jquery.validate');
echo $this->Html->script('jquery.metadata');
?>
<div class="product-box">
<h3><?php echo __('Chi tiết đơn hàng', true); ?></h3>
<?php echo $form->create(array(
		'id'			=> 'formValidation',
		'action' 		=> 'index',
		'enctype' 		=> 'multipart/form-data',
		'autocomplete'	=> 'off'));
	?>
	<h4><?php echo __('Thông tin sản phẩm', true);?></h4>
        <table class="table table-striped">
            <thead>
                <tr>
                    <th><?php echo __('#', true); ?></th>
                    <th><?php echo __('Product name', true); ?></th>
                    <th width="100"><?php echo __('Quantity', true); ?></th>
                    <th><?php echo __('Price', true); ?>(VNĐ)</th>
                    <th><?php echo __('Total', true); ?>(VNĐ)</th>
                    <th><?php echo __('Update', true); ?> </th>
                </tr>
            </thead>
            <tbody>
                <?php 
                    $i = 1;
                    $total = 0;
                   foreach($orders[0]['OrderDetail'] as $item) {
				$sub_total = $item['cost'] * $item['quantity'];
				$total += $sub_total;
		?>
                <tr>
                    <td><?php echo $i; ?></td>
                    <td><?php echo $item['Product']['name_'.$lang]; ?></td>
                    <td><input type="text" id="quantity<?php echo $item['id']; ?>" value="<?php echo $item['quantity']; ?>" size="3" class="input-mini"/></td>
                    <td><?php echo number_format($item['cost'],0,' ','.'); ?></td>
                    <td>
                        <?php if (isset($vipDiscount)) : ?>
                            <?php echo number_format($sub_total,0,' ','.'); ?>
                        <?php else :
                            echo number_format($sub_total * (100-$vipDiscount)/100,0,' ','.');
                            endif;
                        ?>
                    </td>
                    <td><input value="<?php echo __('Update', true); ?>" type="button" onclick="run_update('update',<?php echo $item['id']; ?>);" />
					<input value="<?php echo __('Delete', true); ?>" type="button" onclick="run_update('delete',<?php echo $item['id']; ?>);" /> </td>
                </tr>
                <?php $i++;?>
                <?php } ?>
            </tbody>
            <tfoot>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td><strong><?php echo "Tổng cộng"; ?></td>
                    <td><strong><?php echo number_format($total,0,' ','.'); ?></strong></strong></td>
                    <td></td>
                </tr>
                
            </tfoot>
        </table>
	
	<h4><?php echo __('Thông tin đặt hàng', true);?></h4>
	<div class="input">
		<label><?php echo __('Fullname', true); ?></label>
		<?php echo $orders[0]['Order']['bill_name']; ?>
	</div>
	<div class="input">
		<label><?php echo __('Address', true); ?></label>
		<?php echo $orders[0]['Order']['bill_address']; ?>
	</div>
	<div class="input">
		<label><?php echo __('Phone', true); ?></label>
		<?php echo $orders[0]['Order']['bill_phone']; ?>
	</div>
	
	<h4><?php echo __('Thông tin giao hàng', true);?></h4>
	<div class="input">
		<label><?php echo __('Fullname', true); ?></label>
		<?php echo $orders[0]['Order']['delivery_name']; ?>
	</div>
	<div class="input">
		<label><?php echo __('Address', true); ?></label>
		<?php echo $orders[0]['Order']['delivery_address']; ?>
	</div>
	<div class="input">
		<label><?php echo __('Phone', true); ?></label>
		<?php echo $orders[0]['Order']['delivery_phone']; ?>
	</div>
	<div class="input">
		<label><?php echo __('Chú thích', true); ?></label>
		<?php echo $orders[0]['Order']['note']; ?>
	</div>
	
	<div class="input" style="margin-top:20px">
		<label><?php echo __('Tình trạng', true); ?></label>
		<?php echo ($orders[0]['Order']['status'])? 'Đã xác nhận' : "Đang chờ"; ?>
	</div>
</div>